extension DateTimeExtension on DateTime {
  static const List<String> weeksList = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];

  String get weekStr => weeksList[weekday - 1];

  String get dayFormat {
    DateTime now = DateTime.now();
    DateTime today = DateTime(now.year, now.month, now.day);
    DateTime target = DateTime(year, month, day);
    int difference = target.difference(today).inDays;
    switch (difference) {
      case 0:
        return '今天';
      case 1:
        return '明天';
      case 2:
        return '后天';
      default:
        return weekStr;
    }
  }

  String get mmdd => '${month.toString().padLeft(2, '0')}.${day.toString().padLeft(2, '0')}';

  ///获取当月共有多少天
  int getMonthDay() {
    DateTime dateTime = this;
    DateTime nextDateTime = DateTime(dateTime.year, dateTime.month + 1, 1);
    DateTime currentDateTime = nextDateTime.add(const Duration(days: -1));
    return currentDateTime.day;
  }

  ///获取星期几
  String getWeekDay() {
    DateTime dateTime = this;
    return weeksList[dateTime.weekday];
  }
}
